package com.homework.boot_demo.service;

public class Response <T>{

    private T data;
    private boolean success;
    private String errorMSg;


    public static<K> Response<K> newSuccess(K data){

        Response<K> response = new Response<K>();
        response.setData(data);
        response.setSuccess(true);
        return response;
    }

    public static Response<Void> newFail(String errorMSg){
        Response<Void> response = new Response();
        response.setErrorMSg(errorMSg);
        response.setSuccess(false);
        return response;

    }
    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getErrorMSg() {
        return errorMSg;
    }

    public void setErrorMSg(String errorMSg) {
        this.errorMSg = errorMSg;
    }
}
